using System.Collections.Generic;
using UnityEngine;

//Encoding：UTF-8
public class PlayerController : PlayerBase, IPlayer
{

    public PlayerController(int id)
    {
        playerID = id;
    }

    public void AllowAction(bool playPai, bool chi, bool peng, bool gang, bool anGang, bool jiaGang, bool ting, bool hu, bool ziMo, bool skip)
    {
        action = Action.Non;
        UIPlayer.singleton.SetPlayerButtonShow(playPai, chi, peng, gang, anGang, jiaGang, ting, hu, ziMo, skip);
    }

    public new void DrawOnStart(int[] ids)
    {
        base.DrawOnStart(ids);
        UIPlayer.singleton.AddHand(ids);
    }

    public new void Draw(int id)
    {
        base.Draw(id);
        UIPlayer.singleton.AddPai(id);
    }

    public bool PlayPai()
    {
        if (Pai.selectedPai == null) return false;
        base.PlayPai(Pai.selectedPai.paiID);
        UIPlayer.singleton.DeletePai(Pai.selectedPai);
        return true;
    }

    public new void Peng()
    {
        base.Peng();
        UIPlayer.singleton.DeletePais(new List<int>() { currentPlayPaiID.Item2, currentPlayPaiID.Item2 });
    }

    public new void Gang()
    {
        base.Gang();
        UIPlayer.singleton.DeletePais(new List<int>() { currentPlayPaiID.Item2, currentPlayPaiID.Item2, currentPlayPaiID.Item2 });
    }

    public new void AnGang()
    {
        base.AnGang();
        UIPlayer.singleton.DeletePais(new List<int>() { anGangPaiID[0], anGangPaiID[0], anGangPaiID[0], anGangPaiID[0] });
        anGangPaiID.RemoveAt(0);
    }

    public new void JiaGang()
    {
        base.JiaGang();
        UIPlayer.singleton.DeletePais(new List<int>() { jiaGangPaiID[0] });
        jiaGangPaiID.RemoveAt(0);
    }

    public new bool CanPeng()
    {
        bool res = base.CanPeng();
        if (res) UIPlayer.singleton.SetEffectTip(new List<int>() { currentPlayPaiID.Item2, currentPlayPaiID.Item2 });
        return res;
    }

    public new bool CanGang()
    {
        bool res = base.CanGang();
        if (res) UIPlayer.singleton.SetEffectTip(new List<int>() { currentPlayPaiID.Item2, currentPlayPaiID.Item2, currentPlayPaiID.Item2 });
        return res;
    }

    public new bool CanAnGang()
    {
        bool res = base.CanAnGang();
        if (res)
        {
            int id = anGangPaiID[0];
            UIPlayer.singleton.SetEffectTip(new List<int>() { id, id, id, id });
        }
        return res;
    }

    public new bool CanJiaGang()
    {
        bool res = base.CanJiaGang();
        if (res)
        {
            int id = jiaGangPaiID[0];
            UIPlayer.singleton.SetEffectTip(new List<int>() { id });
        }
        return res;
    }
}
